#!/usr/bin/python3.4
# -*- coding=utf-8 -*-

import logging
import sys
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
from GET_IP import get_ip_address
from GET_MAC import get_mac_address

def arp_request(ipaddr,ifname = 'eno33554944'):
    localip = get_ip_address(ifname)
	localmac = get_mac_address(ifname)
	result_raw = srp(Ether(src=localmac, dst='FF:FF:FF:FF:FF:FF')/ARP(op=1, hwsrc=localmac, hwdst='00:00:00:00:00:00', psrc=localip, pdst=ipaddr), iface = ifname, verbose = False)
	result_list = result_raw[0].res
	for i in range(len(result_list)):
		arp_result_fields = result_list[i][1][1].fields
		print('IP地址: ' + arp_result_fields['psrc'] + '  MAC地址为: ' + arp_result_fields['hwsrc'] )

if __name__ == '__main__':
	arp_request(sys.argv[1])